import { Action, Actor } from 'iflux2'
import { msgTypes } from '../constant/actionTypes.js'
export default class MsgActor extends Actor {
    defaultState (){
        return {
            messages:[]
        }
    }

    @Action(msgTypes.RECEIVE_MESSAGES)
    setOrder(state,messages){
        return state.set('messages', messages);
    }

    @Action(msgTypes.APPEND_MESSAGE)
    appendMessage(state,message){
        return state.update('messages',messages => messages.push(message));
    }
}